package biz.ezcom.design.pattern.flyweight;

import java.util.HashMap;
import java.util.Map;

public class FlyweightFactory {
	private Map<String, Flyweight> map = new HashMap<String, Flyweight>();
	public FlyweightFactory(){
	}
	
	public Flyweight getFlyweight(String key){
		if(!map.containsKey(key)){
			SharedFlyweight shared = new SharedFlyweight();
			shared.setKey(key);
			map.put(key, shared);
			return shared;
		}
		return map.get(key);
	}
}
